<!DOCTYPE html>
<html>

<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0" />
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection">
    <title>个人中心</title>
    <link type="image/x-icon" rel="shortcut icon" href="../images/favicon.ico">
    <link rel="stylesheet" href="../res/mui/css/mui.min.css" />
    <link rel="stylesheet" href="../res/fontAwesome/css/font-awesome.min.css" />
    <link rel="stylesheet" href="../css/common.css" />
    <link rel="stylesheet" href="../css/user.css" />
    <!-- layer -->
    <!-- <link rel="stylesheet" href="../css/layer.css"> -->
</head>

<body>
    <div class="cz_layout bgg">
        <header class="cz_topBar">
            <a href="javascript:history.back();" class="icon_back fa fa-arrow-left"></a>
            <span class="title">个人中心</span>
        </header>
        <div class="cz_container">
            <ul class="mui-table-view mui-table-view-chevron">
                <li class="mui-table-view-cell mui-media">
                    <a class="mui-navigate-right" href="#account">
                        <img class="mui-media-object mui-pull-left head-img" id="head-img" src="../images/user.jpg">
                        <div class="mui-media-body">
                            用户: <span id="name"></span>
                            <p class="mui-ellipsis">账号:<span></span></p>
                        </div>
                    </a>
                </li>
            </ul>
            <ul class="mui-table-view mui-table-view-chevron">
                <li class="mui-table-view-cell">
                    <a href="password.html" class="mui-navigate-right">账号与安全</a>
                </li>
                <li class="mui-table-view-cell">
                    <a href="../cart.html" class="mui-navigate-right">我的购物车</a>
                </li>
                <li class="mui-table-view-cell">
                    <a href="address.html" class="mui-navigate-right">收货地址管理</a>
                </li>
            </ul>
            <div class="p20">
                <a href="javascript:;" class="mui-btn btn_outLogin">退出登录</a>
            </div>
        </div>
        <footer class="cz_tabs">
            <a class="tab_home fa fa-home" href="../index.html"><span>首页</span></a>
            <a class="tab_cate fa fa-bars" href="../cate.html"><span>分类</span></a>
            <a class="tab_cart fa fa-shopping-cart" href="../cart.html"><span>购物车</span></a>
            <a class="tab_user fa fa-user now" href="../user/index.html"><span>会员中心</span></a>
        </footer>
    </div>
    <script src="../res/mui/js/mui.min.js"></script>
    <script src="../assets/vendors/jquery/jquery.min.js"></script>
    <script src="../assets/vendors/layer/layer.js"></script>
    <script>
        $.ajax({
            url: '/api/user/queryUserMessage',
            success: function (msg) {
                if (msg.error == 400) {
                    layer.ready(function () {
                        layer.msg('您还未登录', {
                                shift: 5,
                                time: 2000
                            },
                            function () {
                                location.href =
                                    '/user/login.html?url=/user/index.html'
                            });
                    });
                } else {
                    $('#name').text(msg.username);
                    $('.mui-ellipsis span').text(msg.mobile);
                }
            }
        });
        $('.btn_outLogin').click(function () {
            // alert(1)
            $.ajax({
                url: '/api/user/logout',
                success: function (msg) {
                    if (msg.success) {
                        layer.ready(function () {
                            layer.msg('退出成功', {
                                    shift: 2,
                                    time: 500
                                },
                                function () {
                                    location.href = '/user/login.html'
                                });
                        });

                    }
                }
            });
        });
    </script>
</body>

</html>